<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

	<rich:tabPanel id="subTabs" switchType="ajax"
		selectedTab="#{editRef.selectedTabUpd}">
		<rich:tab label="Ref" switchType="ajax" id="updRefSub"
			ajaxSingle="true">
			
						<a4j:form id="updRefGridForm" ajaxSingle="true">
				<rich:datascroller align="center" for="updRefGrid" maxPages="15"
					page="#{dataTableScrollerBean.scrollerPage}"
					renderIfSinglePage="false" />

				<div style="clear: both;" />
				<rich:panel styleClass="table_add"
					rendered="#{not empty editRef.refHeadSearch}">
					<rich:dataTable id="updRefGrid" var="refHead" rows="3"
						value="#{editRef.refHeadSearch}"
						rendered="#{not empty editRef.refHeadSearch}"
						rowClasses="rvgRowOne,rvgRowTwo"
						style="width:70%; margin-left:15%;">

						<rich:column>
							<f:facet name="header">
								<h:outputText value="Codigo" />
							</f:facet>

							<h:outputText value="#{refHead.cod}" />
						</rich:column>

						<rich:column>
							<f:facet name="header">
								<h:outputText value="Descripcion" />
							</f:facet>

							<h:outputText value="#{refHead.descrip}" />
						</rich:column>


						<rich:column>
							<f:facet name="header">
								<h:outputText value="Operaciones" />
							</f:facet>

							<a4j:commandButton id="RefDelete" value="Borrar"
								ajaxSingle="true"
								action="#{editRef.refHeadToDelete(refHead.cod)}"
								image="/img/icons/delete_data.png"
								onclick="if (!confirm('Esta usted seguro que quiere borrar el registro ?')) return false"
								reRender="updRefGridForm" />
							<rich:toolTip value="Borrar" for="RefDelete" />
							<rich:spacer width="20" />

							<a4j:commandLink id="RefEdit"
								action="#{editRef.refHeadToEdit(refHead.cod)}" ajaxSingle="true"
								oncomplete="#{rich:component('RefModalPanel')}.show()"
								reRender="RefModalPanel">

								<h:graphicImage id="RefDeleteImg" url="/img/icons/edit.png"
									styleClass="actionsImages" />
							</a4j:commandLink>
							<rich:toolTip value="Editar Referencia" for="RefEdit" />
							<rich:spacer width="20" />

							<h:commandLink id="RefDetEdit"
								action="#{editRef.searchRefDet(refHead)}" reRender="subTabs, updRefSub, updRefDet">
								<a4j:support event="onclick"
									action="#{editRef.changeUpdTab('updRefDet')}"></a4j:support>
								<h:graphicImage id="RefDetEditImg"
									url="/img/icons/home.png" styleClass="actionsImages" />
							</h:commandLink>
							<rich:toolTip value="Ver Detalle"
								for="RefDetEdit" />
							<rich:spacer width="20" />


						</rich:column>

					</rich:dataTable>
				</rich:panel>

			</a4j:form>
			
			
			<a4j:form id="updRefForm" ajaxSingle="true">

				<!-- ************************************ -->
				<!-- *****  MODIFICAR REFERENCIA  ***** -->
				<!-- ************************************ -->

				<rich:panel styleClass="form">
					<a4j:outputPanel id="ToMsg">
						<h:messages globalOnly="false" styleClass="message" />
					</a4j:outputPanel>
					<f:facet name="header">
						<h:outputText value="Datos de Referencias" />
					</f:facet>
					<h:panelGrid>
						<div class="attributes">
						<s:decorate
							template="/layout/input.xhtml">
							<ui:define name="label">Codigo</ui:define>
							<h:inputText styleClass="upper" id="RefCode" maxlength="20"
								value="#{editRef.refHeadUpd.cod}" size="5">
								<a4j:support event="onblur" />
							</h:inputText>
							<div class="msg_container"><rich:message for="RefCode" />
							</div>
						</s:decorate>
						<div style="clear: both;" />
						

						<s:decorate
							template="/layout/input.xhtml">
							<ui:define name="label">Descripcion</ui:define>
							<h:inputText styleClass="upper" id="RefCode" maxlength="20"
								value="#{editRef.refHeadUpd.descrip}" size="5">
								<a4j:support event="onblur" />
							</h:inputText>
							<div class="msg_container"><rich:message for="RefCode" />
							</div>
						</s:decorate>
						<div style="clear: both;" />
						</div>

						<s:decorate template="/layout/displayButton.xhtml"
							styleClass="button_form">
							<a4j:commandButton value="Buscar"
								action="#{editRef.searchRef(editRef.refHeadUpd)}"
								styleClass="button" reRender="updRefGridForm, updRefForm"
								oncomplete="window.location.reload()">

							</a4j:commandButton>
							<rich:spacer width="20px" />
							<a4j:commandButton value="Cancelar"
								action="#{editRef.cancelData()}" reRender="updRefForm"
								styleClass="button" oncomplete="window.location.reload()" />

						</s:decorate>

					</h:panelGrid>

				</rich:panel>
			</a4j:form>



			<rich:modalPanel id="RefModalPanel" minwidth="800" minheight="300"
				resizeable="false" autosized="true">
				<f:facet name="header">
					<h:panelGroup>
						<h:outputText value="Actualizar Referencia" />
					</h:panelGroup>
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/img/close.png" style="cursor:pointer"
							id="hideEditApp" />
						<rich:componentControl for="RefModalPanel"
							attachTo="hideEditApp" operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<h:panelGroup id="idEditGroup">
					<!--  **** Include of the update page ****  -->
					<a4j:include viewId="/fms/fms/maintenances/fmsRefEdit.xhtml" />
				</h:panelGroup>
			</rich:modalPanel>
		</rich:tab>

		<rich:tab label="Detalle" switchType="ajax" id="updRefDet"
			immediate="true" ajaxSingle="true">
			<a4j:form id="updRefDetForm" ajaxSingle="true">
				<a4j:outputPanel id="ToMsg">
					<h:messages globalOnly="false" styleClass="message" />
				</a4j:outputPanel>

				<!-- ************************************ -->
				<!-- *****  MODIFICAR DETALLE ***** -->
				<!-- ************************************ -->

				<rich:panel styleClass="form">
					<f:facet name="header">
						<h:outputText value="Filtros" />
					</f:facet>
					<h:panelGrid>
						<div class="attributes"><s:decorate
							template="/layout/input.xhtml">
							<ui:define name="label">Codigo</ui:define>
							<h:inputText styleClass="upper" id="RefDetHeadCode"
								maxlength="20" value="#{editRef.refHeadUpd.cod}" required="true"
								requiredMessage="Favor introduzca un codigo" size="5">
								<a4j:support event="onblur"></a4j:support>
							</h:inputText>
							<div class="msg_container"><rich:message
								for="RefDetHeadCode" /></div>
						</s:decorate>
						<div style="clear: both;" />

						<h:commandButton value="Volver a Cabecera" reRender="subTabs"
							immediate="true">
							<a4j:support event="onclick"
								action="#{editRef.changeUpdTab('updRefSub')}"></a4j:support>
						</h:commandButton></div>


						<s:decorate template="/layout/displayButton.xhtml"
							styleClass="button_form">
							<a4j:commandButton value="Buscar" ajaxSingle="true"
								action="#{editRef.searchRefDet(editRef.refHeadUpd)}"
								styleClass="button"
								reRender="updRefDetGridForm, updRefDetForm">

							</a4j:commandButton>
							<rich:spacer width="20px" />
							<a4j:commandButton value="Cancelar"
								action="#{editRef.cancelData()}"
								reRender="updRefDetForm" styleClass="button"
								oncomplete="window.location.reload()" />

						</s:decorate>

					</h:panelGrid>

				</rich:panel>
			</a4j:form>

			<a4j:form id="updRefDetGridForm" ajaxSingle="true">
				<rich:datascroller align="center" for="updRefDetGrid"
					maxPages="15" page="#{dataTableScrollerBean.scrollerPage}"
					renderIfSinglePage="false" />

				<div style="clear: both;" />
				<rich:panel styleClass="table_add"
					rendered="#{not empty editRef.refDetSearch}">
					<rich:dataTable id="updRefDetGrid" var="refDet" rows="3"
						value="#{editRef.refDetSearch}"
						rendered="#{not empty editRef.refDetSearch}"
						rowClasses="rvgRowOne,rvgRowTwo"
						style="width:70%; margin-left:15%;">


						<rich:column>
							<f:facet name="header">
								<h:outputText value="Codigo Cabecera" />
							</f:facet>

							<h:outputText value="#{refDet.headCode}" />
						</rich:column>
						
						<rich:column>
							<f:facet name="header">
								<h:outputText value="Descripcion" />
							</f:facet>

							<h:outputText value="#{refDet.descrip}" />
						</rich:column>
						
						<rich:column>
							<f:facet name="header">
								<h:outputText value="Descripcion Abrev." />
							</f:facet>

							<h:outputText value="#{refDet.shortname}" />
						</rich:column>
						
						<rich:column>
							<f:facet name="header">
								<h:outputText value="Activo" />
							</f:facet>

							<h:outputText
								value="#{convertAssist.booleanToString(refDet.status)}" />
						</rich:column>



						<rich:column>
							<f:facet name="header">
								<h:outputText value="Operaciones" />
							</f:facet>

							<a4j:commandButton id="RefDetDelete" value="Borrar"
								action="#{editRef.refDetToDelete(refDet.id)}"
								image="/img/icons/delete_data.png"
								onclick="if (!confirm('Esta usted seguro que quiere borrar el registro ?')) return false"
								reRender="updRefDetGridForm" />
							<rich:toolTip value="Borrar" for="RefDetDelete" />
							<rich:spacer width="20" />
							<a4j:commandLink id="RefDetEdit"
								action="#{editRef.refDetToEdit(refDet.id)}"
								oncomplete="#{rich:component('RefDetModalPanel')}.show()"
								reRender="RefDetModalPanel" immediate="true">

								<h:graphicImage id="RefDetDeleteImg" url="/img/icons/edit.png"
									styleClass="actionsImages" />
							</a4j:commandLink>
							<rich:toolTip value="Editar Referencia" for="RefDetEdit" />



						</rich:column>

					</rich:dataTable>
				</rich:panel>

			</a4j:form>


			<rich:modalPanel id="RefDetModalPanel" minwidth="800"
				minheight="300" resizeable="false" autosized="true">
				<f:facet name="header">
					<h:panelGroup>
						<h:outputText value="Actualizar Detalle" />
					</h:panelGroup>
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/img/close.png" style="cursor:pointer"
							id="hideEditRefDet" />
						<rich:componentControl for="RefDetModalPanel"
							attachTo="hideEditRefDet" operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<h:panelGroup id="GroupRefDet">
					<!--  **** Include of the update page ****  -->
					<a4j:include
						viewId="/fms/fms/maintenances/fmsRefDetEdit.xhtml" />
				</h:panelGroup>
			</rich:modalPanel>
		</rich:tab>


	</rich:tabPanel>

</ui:composition>